/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, {Component} from 'react';
import {
    AppRegistry,
    StyleSheet,
    View,
    Image,
    Text,
    StatusBar,
} from 'react-native';
import {Navigator} from 'react-native-deprecated-custom-components'

import LoginAndRegisterPage from './modules/presenters/common/loginAndRegister'
import Main from './modules/presenters/third'
import * as Consts from "react-native-deprecated-custom-components/src/NavigatorSceneConfigs";
import Activity from "./modules/presenters/activity/activity";
import MyNavigator from './modules/comps/normal/myNavigator'

export default class RNDemo1 extends Component {

    render() {
        var rootRoute = {
            component: SplashPage
        };
        return (
            <MyNavigator rootRoute={rootRoute}/>
        );
    }
}

class SplashPage extends Component {
    componentDidMount() {
        this.timer = setTimeout(
            () => {
                var nextRoute = {
                    component: LoginAndRegisterPage,
                };
                this.props.navigator.push(nextRoute);
            },
            3000
        );
    }

    componentWillUnmount() {
        // 请注意Un"m"ount的m是小写
        // 如果存在this.timer，则使用clearTimeout清空。
        // 如果你使用多个timer，那么用多个变量，或者用个数组来保存引用，然后逐个clear
        this.timer && clearTimeout(this.timer);
    }

    render() {
        return (
            <View style={{flex: 1}}>
                <StatusBar hidden={true} translucent={true}/>
                <Image source={require('./modules/img/splash.png')} style={styles.container}>
                </Image>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        width: null,
        height: null,
    },
    welcome: {
        fontSize: 20,
        textAlign: 'center',
        margin: 10,
    },
    instructions: {
        textAlign: 'center',
        color: '#333333',
        marginBottom: 5,
    },
    thumbnail: {
        width: 200,
        height: 260,
    },
    touchables: {
        margin: 10,
        backgroundColor: 'blue',
        width: 250,
        height: 50,
        borderRadius: 20,
        justifyContent: 'center',
    },
    touchablesText: {
        color: 'white',
        fontSize: 20,
        textAlign: 'center',
    },
    imgMode: {
        width: 0,
        height: 0,
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
    },
    backgroundImage: {
        flex: 1,
        alignItems: 'center',
        justifyContent: 'center',
        width: null,
        height: null,
        //不加这句，就是按照屏幕高度自适应
        //加上这几，就是按照屏幕自适应
        resizeMode: Image.resizeMode.contain,
        //祛除内部元素的白色背景
    },
});

// AppRegistry.registerComponent('RNDemo1', () => Main);
AppRegistry.registerComponent('RNDemo1', () => RNDemo1);
// AppRegistry.registerComponent('RNDemo1', () => Activity);
